package bainuo

def execute(data, dlzt) {
    def conn
    try {
        conn = groovy.sql.Sql.newInstance(dlzt.hqcon(2))
        String sql = '''select * from bd_customer 
                        where taxpayerid = ? or name = ? 
                        order by case 
                            when taxpayerid = ? then 0 
                            else 1 
                        end'''
        def params = [data.get("taxpayerid"), data.get("name"), data.get("taxpayerid")]
        def it = conn.firstRow(sql, params)

        if (it == null) {
            return ["state": 0, "Ascript": "未查询到信息", "data": false]
        }

        return ["state": 1, "Ascript": "查询成功", "data": it]

    } catch (Exception e) {
        e.printStackTrace()
        return ["state": 0, "Ascript": "查询错误: ${e.message}", "data": false]
    } finally {
        if (conn != null) {
            conn.close()
        }
    }
}



